<?php
  include_once('staff.php');
  
  if(isset($_REQUEST['subj'])){
    $subj = $_REQUEST['subj'];
  }else{
    $subj = '';
  }
  $sql = "SELECT * FROM elib WHERE subj_id='$subj'";
  $db = connectdb();
  $res = mysql_query($sql,$db);
  //echo $res;
  $list = array();
  if(mysql_num_rows($res) > 0){
    while($row = mysql_fetch_assoc($res)){
		$row['title']=iconv('CP1251','UTF-8',$row['title']);
		$list[] = $row['title'];
		$list[][]=iconv('CP1251','UTF-8',$row['author']);
		$list[][][]=$row['num'];
		$list[][][][]=iconv('CP1251','UTF-8',$row['name']);
		$list[][][][][]=$row['id'];
    } 
  }  
  $tmp = json_encode($list);
  //print_r($list);
  echo $tmp;

?>